package com.tutorial.demo.goods.service;

import com.tutorial.demo.goods.mapper.TbgoodsMapper;
import com.tutorial.demo.goods.pojo.Tbgoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TbgoodsServiceImpl2 {
    @Autowired
    private TbgoodsMapper tbgoodsMapper;

    public int insert(Tbgoods tbgoods){
        int i = 10/0;
        return tbgoodsMapper.insert(tbgoods);
    }

    @Transactional(rollbackFor = Exception.class)
    public int insert1(Tbgoods tbgoods){
        int i = 10/0;
        return tbgoodsMapper.insert(tbgoods);
    }

    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    public int insert2(Tbgoods tbgoods){
        int i = 10/0;
        return tbgoodsMapper.insert(tbgoods);
    }
}
